home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / dist / gdb / munch < prev    next >
Encoding:
Text File  |  1992-04-03  |  1.1 KB  |  36 lines

  1. #!/bin/sh
  2.  
  3. # create an initialization procedure from a list of .o files
  4.  
  5. echo '/* Do not modify this file.  It is created automatically by "munch". */'
  6. echo 'void initialize_all_files () {'
  7.  
  8. NMOPT=""
  9. case $1 in
  10. MUNCH_NM=*)
  11.     MUNCH_NM=`echo $1 | sed 's/MUNCH_NM=//'`; shift ;;
  12. -*)
  13.     NMOPT=$1; shift ;;
  14. esac
  15.  
  16. # make it easy to use a different nm, e.g. for cross-developing
  17.  
  18. MUNCH_NM="${MUNCH_NM-nm} $NMOPT"
  19. if test "`$MUNCH_NM main.o | egrep main | egrep FUNC | egrep GLOB`" != "" ; then
  20.     # System V Release 4 style nm
  21.     $MUNCH_NM $* | egrep '|__?initialize_' | egrep FUNC | \
  22.     sed -e 's/^.*\(_initialize_[a-zA-Z0-9_]*\).*$/   {extern void \1 (); \1 ();}/'
  23. elif test "`$MUNCH_NM main.o | egrep '[TD] _?main$'`" = "" ; then
  24.     # System V style nm
  25.     shift;
  26.     $MUNCH_NM $* | egrep '_initialize_.*' | egrep '\.text'|\
  27.     sed -e 's/^.*\(_initialize_[a-zA-Z0-9_]*\).*/   {extern void \1 (); \1 ();}/'
  28. else
  29.     # BSD style nm
  30.     # We now accept either text or data symbols, since the RT/PC uses data.
  31.     $MUNCH_NM -p $* | egrep '[TD] *_?[_.]initialize_' | \
  32.     sed -e 's/^.*\(initialize_.*\)/    {extern void _\1 (); _\1 ();}/'
  33. fi
  34.  
  35. echo '}'
  36.